<?php
 require './lib/ConnectDB.php';
$connect = ConnectDB::getInstace(); 
$deleteImgId = (int)addslashes(mysqli_real_escape_string($connect->cDB(), $_GET['d_id']));

if(empty($deleteImgId) !=true && is_int($deleteImgId)==true ){
    $unlinkImg = $connect->cDB()->query("SELECT users.username,images.img_path FROM users,images WHERE users.id_user=images.id_user AND images.id_img='$deleteImgId'")->fetch_assoc();
   
    $connect->cDB()->query("DELETE FROM images WHERE id_img='$deleteImgId'");
   unlink("img".DIRECTORY_SEPARATOR.$unlinkImg['username'].DIRECTORY_SEPARATOR.$unlinkImg['img_path']);
   ?>
<script type="text/javascript">alert("Снимката беше изтрита успешно!");
 self.location.href="dashboard.php";
</script>
<?php
}?>